package app.itw.tison.cloud.order_service.service.impl;

import app.itw.tison.cloud.order_service.service.OrderService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;
import app.itw.tison.cloud.model.Order;

@Service
public class OrderServiceImpl implements OrderService {

  //初始化假数据
  public static List<Order> list = new ArrayList<>();

  /*static {
    for (int i = 0; i < 10; i++) {
      list.add(new Order((i+1000)+"", i+"", "请尽快安排发货，谢谢！", i*10,new Date()));
    }
  }*/

  //查询某个订单
  @Override
  public Order getOrderByID(String id) {
    for (Order order:list) {
      if (order.getId().equals(id)) {
        return order;
      }
    }
    return null;
  }

  //查询list
  @Override
  public List<Order> getOrderList() {
    return list;
  }

  //查询用户的订单
  @Override
  public Order getOrderByUserID(String userId) {
    for (Order order:list) {
      if (order.getUid().equals(userId)) {
        return order;
      }
    }
    return null;
  }


}
